package cz.muni.fi.pa165.library.backend;

import java.util.List;

/**
 *
 * @author Matúš Abaffy
 */
public interface ReaderDAO {

    /**
     * Generates unique id for the new reader and stores this reader into
     * database.
     *
     * @param reader reader entity to be created
     * @return created reader with new id
     * @throws IllegalArgumentException if reader is null, reader's attributes
     * are not correct or sufficient (especially if there is already a reader in
     * the database with same birth number or email)
     */
    public Reader createReader(Reader reader) throws IllegalArgumentException;

    /**
     * Returns a list of all readers in the database.
     *
     * @return list of all books in the database.
     */
    public List<Reader> findAllReaders();

    /** 
     * Returns readers with name and email like those given. Parameter equal to null
     * is considered as empty String.
     *
     * @param firstName reader's first name
     * @param surname reader's surname
     * @param email reader's email
     * @return list of readers with given name and email
     */
    public List<Reader> findReaderByFull(String firstName, String surname, String email);
    
    /**
     * Returns reader with given id.
     *
     * @param id reader's id
     * @return reader with given id or null if such reader does not exist
     * @throws IllegalArgumentException if id is null
     */
    public Reader findReaderById(Long id) throws IllegalArgumentException;

    /**
     * Returns readers with given name.
     *
     * @param firstName reader's first name
     * @param surname reader's surname
     * @return list of readers with given name
     * @throws IllegalArgumentException if name is null or empty string
     */
    public List<Reader> findReaderByName(String firstName, String surname) throws IllegalArgumentException;

    /**
     * Returns reader with given birth number.
     *
     * @param birthNumber reader's birth number
     * @return reader with given birth number or null if such reader does not
     * exist
     * @throws IllegalArgumentException if birthNumber is null or empty string
     */
    public Reader findReaderByBirthNumber(String birthNumber) throws IllegalArgumentException;

    /**
     * Returns reader with given email.
     *
     * @param email reader's email
     * @return reader with given email or null if such reader does not exist
     * @throws IllegalArgumentException if email is null or empty string
     */
    public Reader findReaderByEmail(String email) throws IllegalArgumentException;

    /**
     * Updates reader that is already in database.
     *
     * @param reader updated reader to be stored into database
     * @throws IllegalArgumentException if reader is null or reader's attributes
     * are not correct
     */
    public void updateReader(Reader reader) throws IllegalArgumentException;

    /**
     * Deletes reader from database.
     *
     * @param reader reader to be deleted from database
     * @throws IllegalArgumentException if reader is null
     */
    public void deleteReader(Reader reader) throws IllegalArgumentException;
    
     /**
     * Try to authentize user.
     *
     * @param email reader's email
     * @param password reader's password
         * @return reader instace if authentizazion is sucessfull, null otherwise
     */
     public Reader authentize(String email, String password);

}
